<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	private $_data = array();
	public $type=array(
		
	);
	public function __construct(){
		parent::__construct();
		$this->load->helper('url');
		
		//$this->load->model('product_model');
		//$this->type=$this->product_model->get_producttype();
	}
	
	public function index()
	{
		// $this->output->cache(1);
		$this->benchmark->mark('code_start');

		$this->_data=array();
		$this->_data['title'] = ' 欢迎光临';
		
		// $this->_data['product'] = $this->product_model->get_product('*',6);
		// $this->_data['producttype'] = $this->product_model->get_producttype();
		// // Some code happens here

		$this->load->model('product_model');
		$products = $this->product_model->get_lists('a.id,a.title,a.imagethumb', "a.imagethumb is not null" , 'a.id desc', 16);
		$this->_data['marqueen_products'] = $products;


		$this->load->view('index', $this->_data);

		$this->benchmark->mark('code_end');


		// echo $this->benchmark->elapsed_time('code_start', 'code_end');
		
	}
	public function dg($id=0,$t=array()){
		$sort = array();
		if(empty($t)){
			$t = $this->type;
		}
		foreach ($t as $k=>$v){
			if($v->parentid==$id){
				array_push($sort, $v);
			}
		}
		
		return $sort;
		
	}
	public function t(){
		echo '<pre>';
		print_r($this->dg());
		echo '<br />end of dg----start type--<br />';
		print_r($this->type);
		echo '</pre>';
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */